cssrgbavalue: Add an opaque white singleton
authorTimm Bäder <mail@baedert.org>
Fri, 23 Aug 2019 06:13:20 +0000 (08:13 +0200)
committerTimm Bäder <mail@baedert.org>
Mon, 9 Sep 2019 15:36:23 +0000 (17:36 +0200)
Used a few hundred times in the widget-factory.

gtk/gtkcssrgbavalue.c

index f840160bde9ae38adbc270d37e63242c01a1eda5..ab3d1806484fc542b0b03336b8398960653b08b9 100644 (file)
@@ -109,6 +109,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_RGBA = {
 
 static GtkCssValue transparent_black_singleton = (GtkCssValue) { &GTK_CSS_VALUE_RGBA, 1, { 0, 0, 0, 0 }};
 static GtkCssValue transparent_white_singleton = (GtkCssValue) { &GTK_CSS_VALUE_RGBA, 1, { 1, 1, 1, 0 }};
+static GtkCssValue opaque_white_singleton      = (GtkCssValue) { &GTK_CSS_VALUE_RGBA, 1, { 1, 1, 1, 1 }};
 
 GtkCssValue *
 _gtk_css_rgba_value_new_from_rgba (const GdkRGBA *rgba)
@@ -129,6 +130,13 @@ _gtk_css_rgba_value_new_from_rgba (const GdkRGBA *rgba)
           rgba->blue == 0)
         return _gtk_css_value_ref (&transparent_black_singleton);
     }
+  else if (gdk_rgba_is_opaque (rgba))
+    {
+      if (rgba->red == 1 &&
+          rgba->green == 1 &&
+          rgba->blue == 1)
+        return _gtk_css_value_ref (&opaque_white_singleton);
+    }
 
   value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_RGBA);
   value->rgba = *rgba;